//
//  AFNModel.m
//  New
//
//  Created by 才诗琦 on 16/1/16.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "AFNModel.h"
#import <AFNetworking.h>
@implementation AFNModel
+(void)GETWithHandler:(NSString *)str completion:(NETBLOCK)netBlock
{
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    str = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:str]];
   
   
    //创建session管理器
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
//    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json",nil];
    [manager GET:str parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
//        id result = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        
        return  netBlock(responseObject);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@", error);
    }];
    
    
}
@end
